<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('运维页面')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>手机号：</label>
                            <input type="text" name="mobile" id = "mobile"/>
                        </li>
                        <li>
                            <label>任务ID：</label>
                            <input type="text" name="itemId" id = "itemId"/>
                        </li>
                        <li>
                            <button class="btn btn-primary btn-rounded btn-sm" type="button" onclick="submitHandler()">&nbsp;提交</button>
                        </li>
                        <li></li>
                        <li></li>
                        <li></li>
                        <li>
                            <button class="btn btn-warning btn-rounded btn-sm" type="button" onclick="submitRefreshHandler()">&nbsp;刷新缓存</button>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:inline="javascript">
    // var editFlag = [[${@permission.hasPermi('tool:operation:checkUser')}]];
    var prefix = ctx + "operation";

    $(function() {
        var options = {
            // url: prefix + "/list",
            modalName: "运维页面",
            columns: [
                //     {
                //     checkbox: true
                // },
                // {
                //     field: 'id',
                //     title: '',
                //     visible: false
                // },
                {
                    field: 'mobileData',
                    title: '返回内容'
                }
            ]
        };
        $.table.init(options);
    });


    function submitHandler() {
        var mobile = $("#mobile").val();
        var itemId = $("#itemId").val();
        if (mobile == '' || mobile == undefined || mobile.length != 11){
            $.modal.alertWarning("请输入正确的手机号")
            return;
        }
        if (itemId == '' || itemId == undefined){
            $.modal.alertWarning("请输入正确的任务ID")
            return;
        }
        $.ajax({
            type: "post",
            url: prefix + "/checkUser",
            data: {
                'mobile': mobile,
                'itemId': itemId
            },
            dataType: 'json',
            success: function(result) {
                if (result.code == 0) {
                    if (result.data.status == '000') {
                        alert(result.data.data)
                    } else {
                        alert("请求异常");
                    }
                }
            },
        });
    }


    function submitRefreshHandler() {
        $.ajax({
            type: "post",
            url: prefix + "/refresh",
            dataType: 'json',
            success: function(result) {
                if (result.code == 0) {
                    if (result.data.status == '000') {
                        alert(result.data.message)
                    } else {
                        alert("刷新失败");
                    }
                }
            },
        });
    }
</script>
</body>
</html>